package com.example.lin.day9_17_bitmap;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorSpace;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

    private ImageView iv_show1;
    private ImageView iv_show2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        iv_show1 = findViewById(R.id.iv_show1);
        iv_show2 = findViewById(R.id.iv_show2);

        //通过BitmapFactory 解码 在资源文件中的图片
        Bitmap dogBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.dog);

            File dir = Environment.getExternalStorageDirectory();
            File file = new File(dir, "big.jpg");

            Bitmap bitmap1 = BitmapFactory.decodeFile(file.getAbsolutePath());
            Bitmap bitmap2 = BitmapFactory.decodeFile(file.getAbsolutePath());
            Bitmap bitmap3 = BitmapFactory.decodeFile(file.getAbsolutePath());
            Bitmap bitmap4 = BitmapFactory.decodeFile(file.getAbsolutePath());
            Bitmap bitmap5 = BitmapFactory.decodeFile(file.getAbsolutePath());
            Bitmap bitmap6 = BitmapFactory.decodeFile(file.getAbsolutePath());
            Bitmap bitmap7 = BitmapFactory.decodeFile(file.getAbsolutePath());
            Bitmap bitmap8 = BitmapFactory.decodeFile(file.getAbsolutePath());


        iv_show1.setImageBitmap(bitmap1);
        //获取位图的宽度
        int width = dogBitmap.getWidth();
        //获取位图的高度
        int height = dogBitmap.getHeight();

        Bitmap bitmap = Bitmap.createBitmap(dogBitmap);
        Bitmap copy = bitmap.copy(Bitmap.Config.ARGB_8888, true);

        Toast.makeText(this, ""+copy.isMutable(), Toast.LENGTH_SHORT).show();
        copy.eraseColor(Color.RED);



        iv_show2.setImageBitmap(bitmap2);

    }
}
